#include "HelloWorldScene.h"

USING_NS_CC;

CCScene* HelloWorld::scene()
{
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();
    
    // 'layer' is an autorelease object
    HelloWorld *layer = HelloWorld::create();

    // add layer as a child to scene
    scene->addChild(layer);

    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	CCMenuItemFont::setFontSize(60);
	CCMenuItemFont::setFontName("Doodle Digit");
	CCMenuItemFont* pPlay = CCMenuItemFont::create("New Game");
	pPlay->setPosition(winSize.width / 2, winSize.height / 2 - 100);
	CCMenuItemFont* pAbout = CCMenuItemFont::create("About");
	pAbout->setPosition(winSize.width / 2, winSize.height / 2 - 200);
	CCMenuItemFont* pExit = CCMenuItemFont::create("Exit", this, menu_selector(HelloWorld::menuCloseCallback));
	pExit->setPosition(winSize.width / 2, winSize.height / 2 - 300);

    // create menu, it's an autorelease object
	CCMenu* pMenu = CCMenu::create(pPlay, pAbout, pExit, NULL);
	pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

	CCLabelTTF *pLabel = CCLabelTTF::create("Don't Touch", "Doodle Digit", 100);
	pLabel->setPosition(ccp(winSize.width / 2, winSize.height / 2 + 200));
	this->addChild(pLabel);
    
    return true;
}


void HelloWorld::menuCloseCallback(CCObject* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
#else
    CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
#endif
}
